// $Id: Place.cs 124 2007-05-28 15:51:51Z xavex2k $

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
using Diagram.Model;
using PetriDiagram.Model;

namespace PetriDiagram
{
    [Serializable]
    public class Place : PetriNetEntity
    {
        private int tokens;

        public Place( PetriNetModel net )
            : base( net )
        { }

        public override ICollection<PetriNetEntity> Inputs
        {
            get
            {
                return new ReadOnlyCollection<PetriNetEntity>( Net.GetInputs( this ) as IList<PetriNetEntity> );
            }
        }

        public override ICollection<PetriNetEntity> Outputs
        {
            get
            {
                return new ReadOnlyCollection<PetriNetEntity>( Net.GetOutputs( this ) as IList<PetriNetEntity> );
            }
        }

        public int Tokens
        {
            get { return tokens; }
            set
            {
                tokens = value;
                InvokeChanged();
            }
        }

        //public override Entity Clone()
        //{
        //    return new Place( Net );
        //}

        public override Diagram.IUndoable GetInstance()
        {
            return new Place( Net );
        }

        public override string CreateDefaultName()
        {
            return NameManager.Instance.GetName( GetType(), "p" );
        }
    }
}
